using System;
using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities
{
    /// <summary>
    /// 异常日志实体
    /// 用于记录系统运行过程中发生的异常和错误信息
    /// </summary>
    public class ExceptionLog : ITenantEntity
    {
        /// <summary>
        /// 异常日志标识符
        /// </summary>
        public long Id { get; set; }
        
        /// <summary>
        /// 跟踪标识符
        /// 用于关联同一次请求的多个异常记录
        /// </summary>
        public string? TraceId { get; set; }
        
        /// <summary>
        /// 关联ID
        /// 分布式环境下的请求关联标识
        /// </summary>
        public string? CorrelationId { get; set; }
        
        /// <summary>
        /// 异常级别
        /// 如：Warning、Error、Critical、Fatal
        /// </summary>
        public string ExceptionLevel { get; set; } = string.Empty;
        
        /// <summary>
        /// 异常类型
        /// 异常的完整类型名称
        /// </summary>
        public string ExceptionType { get; set; } = string.Empty;
        
        /// <summary>
        /// 异常消息
        /// 异常的详细描述信息
        /// </summary>
        public string ExceptionMessage { get; set; } = string.Empty;
        
        /// <summary>
        /// 堆栈跟踪
        /// 异常发生时的完整堆栈信息
        /// </summary>
        public string? StackTrace { get; set; }
        
        /// <summary>
        /// 内部异常
        /// 内部异常的详细信息（JSON格式）
        /// </summary>
        public string? InnerException { get; set; }
        
        /// <summary>
        /// 时间戳
        /// 异常发生的精确时间
        /// </summary>
        public DateTime Timestamp { get; set; }
        
        /// <summary>
        /// 用户标识符
        /// 触发异常的用户ID
        /// </summary>
        public string? UserId { get; set; }
        
        /// <summary>
        /// 用户名称
        /// 触发异常的用户名
        /// </summary>
        public string? UserName { get; set; }
        
        /// <summary>
        /// 请求路径
        /// HTTP请求的路径信息
        /// </summary>
        public string? RequestPath { get; set; }
        
        /// <summary>
        /// HTTP方法
        /// 如：GET、POST、PUT、DELETE
        /// </summary>
        public string? HttpMethod { get; set; }
        
        /// <summary>
        /// 请求参数
        /// HTTP请求的参数信息（JSON格式）
        /// </summary>
        public string? RequestParameters { get; set; }
        
        /// <summary>
        /// IP地址
        /// 客户端的IP地址
        /// </summary>
        public string? IpAddress { get; set; }
        
        /// <summary>
        /// 用户代理
        /// 客户端的用户代理字符串
        /// </summary>
        public string? UserAgent { get; set; }
        
        /// <summary>
        /// 应用程序名称
        /// 产生异常的应用程序或模块名称
        /// </summary>
        public string? ApplicationName { get; set; }
        
        /// <summary>
        /// 服务器名称
        /// 产生异常的服务器主机名
        /// </summary>
        public string? ServerName { get; set; }
        
        /// <summary>
        /// 线程ID
        /// 产生异常的线程标识符
        /// </summary>
        public int? ThreadId { get; set; }
        
        /// <summary>
        /// 额外数据
        /// 其他相关的上下文信息（JSON格式）
        /// </summary>
        public string? AdditionalData { get; set; }
        
        /// <summary>
        /// 是否已修复
        /// 标记异常是否已经被修复
        /// </summary>
        public bool IsFixed { get; set; } = false;
        
        /// <summary>
        /// 修复时间
        /// 异常修复的时间
        /// </summary>
        public DateTime? FixedAt { get; set; }
        
        /// <summary>
        /// 修复说明
        /// 异常修复的详细说明
        /// </summary>
        public string? FixDescription { get; set; }
        
        /// <summary>
        /// 租户ID
        /// 多租户环境下的租户标识
        /// </summary>
        public string TenantId { get; set; } = string.Empty;
        
        /// <summary>
        /// 创建时间
        /// 日志记录创建的时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        
        /// <summary>
        /// 更新时间
        /// 日志记录最后更新的时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; }

        /// <summary>
        /// 异常来源
        /// 异常发生的源代码位置或组件
        /// </summary>
        public string? Source { get; set; }

        /// <summary>
        /// 目标站点
        /// 异常发生的目标方法或站点
        /// </summary>
        public string? TargetSite { get; set; }

        /// <summary>
        /// 帮助链接
        /// 异常相关的帮助信息链接
        /// </summary>
        public string? HelpLink { get; set; }

        /// <summary>
        /// 异常数据
        /// 异常对象中的附加数据
        /// </summary>
        public string? Data { get; set; }

        /// <summary>
        /// 请求数据
        /// 请求的完整数据信息
        /// </summary>
        public string? RequestData { get; set; }

        /// <summary>
        /// 修复人员
        /// 修复异常的人员标识
        /// </summary>
        public string? FixedBy { get; set; }

        /// <summary>
        /// 修复备注
        /// 修复过程的详细备注
        /// </summary>
        public string? FixNotes { get; set; }
    }
}
